package com.android.yummycookies.util;

import android.util.Log;

import com.android.yummycookies.BuildConfig;

public class Validator {

	
	public static void checkGreaterThan(String TAG, String varName,int value, String maxVarName, int maxValue){
		if (value < maxValue) {
			if (BuildConfig.DEBUG) {
				Log.d(TAG, String.format("Defined %s (%d) lesser than %s (%d)",
						varName, value, maxVarName, maxValue));
			}
			throw new IllegalArgumentException(String.format("Defined %s (%d) lesser than %s (%d)",
					varName, value, maxVarName, maxValue));
		}
	}

	public static void checkLesserThan(String TAG, String varName,int value, String minVarName, int minValue){
		if (value > minValue) {
			if (BuildConfig.DEBUG) {
				Log.d(TAG, String.format("Defined %s (%d) greater than %s (%d)",
						varName, value, minVarName, minValue));
			}
			throw new IllegalArgumentException(String.format("Defined %s (%d) greater than %s (%d)",
					varName, value, minVarName, minValue));
		}
	}
	
	public static void checkIsPositive(String TAG, String varName,int value){
		if (value < 0) {
			if (BuildConfig.DEBUG) {
				Log.d(TAG, String.format("Defined %s (%d) not positive",
						varName, value));
			}
			throw new IllegalArgumentException(String.format("Defined %s (%d) not positive",
					varName, value));
		}
	}
	
	public static void checkIsPositiveOrNull(String TAG, String varName,int value){
		if (value <= 0) {
			if (BuildConfig.DEBUG) {
				Log.d(TAG, String.format("Defined %s (%d) not positive or null",
						varName, value));
			}
			throw new IllegalArgumentException(String.format("Defined %s (%d) not positive or null",
					varName, value));
		}
	}
}
